package api.cie.rss;

import java.net.MalformedURLException;
import java.net.URL;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class SetFluxURLActivity extends Activity implements View.OnClickListener{
	
	private Button annuler;
	private Button add;
	private EditText url;
	
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.set_flux_url);
	    url = (EditText)findViewById(R.id.url);
		annuler = (Button)findViewById(R.id.btnAnl);
		annuler.setOnClickListener(this);
		
        add = (Button)findViewById(R.id.btnAdd);
		add.setOnClickListener(this);
        
	}


	@Override
	public void onClick(View view) {
		if (view == add) {
			String urlText = url.getText().toString();
			try {
				URL u = new URL(urlText);
			} catch (MalformedURLException e) {
				  Builder builder = new AlertDialog.Builder(view.getContext());
				  builder.setTitle("Error");
				 	         
				  builder.setMessage("Mal Formed URL !!!");
				  builder.setPositiveButton("Ok",null);
			}
			Intent intent1 = new Intent(this, AddFluxActivity.class);
			Bundle bundle = new Bundle();
			bundle.putString("url", urlText);
			intent1.putExtras(bundle);
			startActivity(intent1);
		}
		else if(view == annuler){
			Intent intent = new Intent(this, FluxListActivity.class);
			startActivity(intent);
		}
	}

}
